# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "controllers",
    srcs = [
        "data_privacy.go",
        "errors.go",
        "launch_query.go",
        "mutation_executor.go",
        "proto_utils.go",
        "query_executor.go",
        "query_flags.go",
        "query_plan_debug.go",
        "query_result_forwarder.go",
        "server.go",
    ],
    importpath = "px.dev/pixie/src/vizier/services/query_broker/controllers",
    # TODO(PP-2567): Fix this visibility.
    visibility = [
        "//src/carnot:__subpackages__",
        "//src/e2e_test/vizier/planner:__subpackages__",
        "//src/utils/plandebugger:__subpackages__",
        "//src/vizier:__subpackages__",
    ],
    deps = [
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/api/proto/vizierpb:vizier_pl_go_proto",
        "//src/carnot/carnotpb:carnot_pl_go_proto",
        "//src/carnot/goplanner:go_default_library",
        "//src/carnot/planner/compilerpb:compiler_status_pl_go_proto",
        "//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
        "//src/carnot/planner/plannerpb:func_args_pl_go_proto",
        "//src/carnot/planpb:plan_pl_go_proto",
        "//src/carnot/queryresultspb:query_results_pl_go_proto",
        "//src/carnot/udfspb:udfs_pl_go_proto",
        "//src/common/base/statuspb:status_pl_go_proto",
        "//src/operator/apis/px.dev/v1alpha1",
        "//src/shared/services/authcontext",
        "//src/shared/services/utils",
        "//src/shared/types/typespb:types_pl_go_proto",
        "//src/table_store/schemapb:schema_pl_go_proto",
        "//src/utils",
        "//src/vizier/funcs/go",
        "//src/vizier/messages/messagespb:messages_pl_go_proto",
        "//src/vizier/services/metadata/metadatapb:service_pl_go_proto",
        "//src/vizier/services/query_broker/querybrokerenv",
        "//src/vizier/services/query_broker/tracker",
        "//src/vizier/utils/messagebus",
        "@com_github_dustin_go_humanize//:go-humanize",
        "@com_github_emicklei_dot//:dot",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_lestrrat_go_jwx//jwa",
        "@com_github_lestrrat_go_jwx//jwe",
        "@com_github_lestrrat_go_jwx//jwk",
        "@com_github_nats_io_nats_go//:nats_go",
        "@com_github_sirupsen_logrus//:logrus",
        "@com_github_spf13_cast//:cast",
        "@com_github_spf13_pflag//:pflag",
        "@com_github_spf13_viper//:viper",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//metadata",
        "@org_golang_google_grpc//status",
        "@org_golang_x_sync//errgroup",
    ],
)

go_test(
    name = "controllers_test",
    srcs = [
        "launch_query_test.go",
        "mutation_executor_test.go",
        "proto_utils_test.go",
        "query_executor_test.go",
        "query_flags_test.go",
        "query_result_forwarder_test.go",
        "server_test.go",
    ],
    embed = [":controllers"],
    deps = [
        "//src/api/proto/vizierpb:vizier_pl_go_proto",
        "//src/api/proto/vizierpb/mock",
        "//src/carnot/carnotpb:carnot_pl_go_proto",
        "//src/carnot/carnotpb/mock",
        "//src/carnot/planner/compilerpb:compiler_status_pl_go_proto",
        "//src/carnot/planner/distributedpb:distributed_plan_pl_go_proto",
        "//src/carnot/planner/plannerpb:func_args_pl_go_proto",
        "//src/carnot/planpb:plan_pl_go_proto",
        "//src/carnot/queryresultspb:query_results_pl_go_proto",
        "//src/common/base/statuspb:status_pl_go_proto",
        "//src/shared/services/authcontext",
        "//src/shared/types/typespb:types_pl_go_proto",
        "//src/table_store/schemapb:schema_pl_go_proto",
        "//src/utils",
        "//src/utils/testingutils",
        "//src/vizier/messages/messagespb:messages_pl_go_proto",
        "//src/vizier/services/metadata/metadatapb:service_pl_go_proto",
        "//src/vizier/services/query_broker/controllers/mock",
        "//src/vizier/services/query_broker/querybrokerenv",
        "//src/vizier/services/query_broker/tracker",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//proto",
        "@com_github_gogo_protobuf//types",
        "@com_github_golang_mock//gomock",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)
